<script>
function getFrameURL(host) {
  var result = "http://" + host;
  if (location.port) {
    result += ":";
    result += location.port;
  }
  result += location.pathname;
  return result;
}

var iframe = document.createElement("iframe");
iframe.src = getFrameURL("app.com");
document.documentElement.appendChild(iframe);
</script>
